<template>
    <div>
        <h2>房号信息录入页面</h2>
        
        <table>
            <tr>
                <td>房号名称</td>
                <td>
                    <input type="text" v-model="data.fhmc">
                </td>
            </tr>
             <tr>
                <td>房号备注</td>
                <td>
                     <input type="text" v-model="data.fhbz">

                </td>
            </tr>
                  <tr>
                <td>房号状态</td>
                <td>
                     <input type="checkbox" v-model="data.zt">选中表示上架未选中表示下架

                </td>
            </tr>
             <tr>
                <td></td>
                <td>
                    <input type="button" value="录入" @click="add">
                </td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';

const data=ref({
      "fhid": 0,
  "fhmc": "",
  "fhbz": "",
  "fhcjsj": "2025-06-16T08:30:24.214Z",
  "fhnrsj": "2025-06-16T08:30:24.214Z",
  "zt": true
})

const add=()=>{
    axios.post("https://localhost:7258/api/roomfh/fhadd",data.value).then(res=>{
        if(res.data==-1){
            alert("相同的房号的不能录入多次")
        }else if(res.data>0){
            alert("房型录入成功");
            location.href="/fhxs"
        }else{
            alert("录入失败");
        }
    })
}

</script>

<style scoped>

</style>